package com.swallow.auth.domain.auth.model;

import com.swallow.auth.common.utils.SpringUtils;
import com.swallow.auth.domain.auth.repository.gateway.IAuthGateway;
import lombok.Data;

import java.util.Map;

/**
 * @author: 18310740596@163.com
 * @date: 2024-05-11 00:34:06
 * @version: v1.0
 * @describe: class responsibility
 */
@Data
public class SmsValObj {
    /**
     *  发送手机号
     */
    private String mobile;
    /**
     *  短信发送类型 REGISTER-注册  PWD-密码修改
     */
    private String smsType;

    /**
     *  注册短信模板
     */
    public void sendRegisterSms(Integer captchaCode) {
        IAuthGateway authGateway = SpringUtils.getBean(IAuthGateway.class);

        SmsType smsByType = SmsType.findSmsByType(getSmsType());
        // 发送短信
        authGateway.sendCaptcha(getMobile(), smsByType.getTemplateCode(), Map.of("code", captchaCode));
    }
}
